package com.taiji.web.controller.message;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.taiji.common.annotation.Log;
import com.taiji.common.core.controller.BaseController;
import com.taiji.common.core.domain.AjaxResult;
import com.taiji.common.enums.BusinessType;
import com.taiji.message.domain.OrderWarn;
import com.taiji.message.service.IOrderWarnService;
import com.taiji.common.utils.poi.ExcelUtil;
import com.taiji.common.core.page.TableDataInfo;

/**
 * 工单消息Controller
 * 
 * @author a22999
 * @date 2023-06-21
 */
@RestController
@RequestMapping("/orderWarning/orderWarning")
@Api(tags = "定时调度信息")
public class OrderWarnController extends BaseController
{
    @Autowired
    private IOrderWarnService orderWarnService;

    /**
     * 查询工单消息列表
     */
    @PreAuthorize("@ss.hasPermi('orderWarning:orderWarning:list')")
    @GetMapping("/list")
    @ApiOperation("查询定时调度信息列表")
    public TableDataInfo list(OrderWarn orderWarn)
    {
        startPage();
        List<OrderWarn> list = orderWarnService.selectOrderWarnList(orderWarn);
        return getDataTable(list);
    }

    /**
     * 导出工单消息列表
     */
    @PreAuthorize("@ss.hasPermi('orderWarning:orderWarning:export')")
    @Log(title = "工单消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderWarn orderWarn)
    {
        List<OrderWarn> list = orderWarnService.selectOrderWarnList(orderWarn);
        ExcelUtil<OrderWarn> util = new ExcelUtil<OrderWarn>(OrderWarn.class);
        util.exportExcel(response, list, "工单消息数据");
    }

    /**
     * 获取工单消息详细信息
     */
    @ApiOperation("获取定时调度信息详细信息")
    @PreAuthorize("@ss.hasPermi('orderWarning:orderWarning:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(orderWarnService.selectOrderWarnById(id));
    }

    /**
     * 新增工单消息
     */
    @PreAuthorize("@ss.hasPermi('orderWarning:orderWarning:add')")
    @Log(title = "工单消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderWarn orderWarn)
    {
        return toAjax(orderWarnService.insertOrderWarn(orderWarn));
    }

    /**
     * 修改工单消息
     */
    @PreAuthorize("@ss.hasPermi('orderWarning:orderWarning:edit')")
    @Log(title = "工单消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderWarn orderWarn)
    {
        return toAjax(orderWarnService.updateOrderWarn(orderWarn));
    }

    /**
     * 删除工单消息
     */
    @PreAuthorize("@ss.hasPermi('orderWarning:orderWarning:remove')")
    @Log(title = "工单消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(orderWarnService.deleteOrderWarnByIds(ids));
    }
}
